POV-Ray : Newsgroups : povray.programming : [RFC] Little isosurface patch ? : Re: [RFC] Little isosurface patch ? Server Time
3 Jul 2024 05:56:25 EDT (-0400)
  Re: [RFC] Little isosurface patch ?  
From: Wolfgang Wieser
Date: 27 Feb 2004 09:20:21
Message: <403f5224@news.povray.org>
Wolfgang Wieser wrote:

> Thorsten Froehlich wrote:
> 
>> Why not just
>> 
>>     if(EP2->f < 0)
>>     {
>>          if(EP1->f > 0.0)
>>              ISOSRF->tl = 0.5*(EP2->t+EP1->t);
>>          else
>>              ISOSRF->tl = EP2->t;
>>          return true;
>>     }
>>     else return false;
>> 
> [...]
> i.e. the average. We could even do a linear interpolation which should be
> much better: We know the f and the t values!
> 
I now suggest the following: This does a linar interpolation and I verified 
using my current mars rendering that it removes even more (_all_!) 
spurious black dots. 

---------------------------------------
if(EP2->f<=0.0)
{
    if(EP1->f >= 0.0)
    {
        double df = EP1->f-EP2->f;
        // Need to calc (EP1->t*EP2->f - EP2->t*EP1->f) / df
        // in a numerically stable way. 
        if(df>1e-14)
            ISOSRF->tl = EP2->t + t21*EP2->f/df;
        else
            ISOSRF->tl = 0.5*(EP2->t+EP1->t);
    }
    else
        ISOSRF->tl = EP2->t;
    return true;
}
return false;
---------------------------------------

The 1e-14 is just there to prevent a division by zero in 
case the isosurface has zero gradient (along the ray) at the 
intersection. Maybe we can even use smaller values. 

Wolfgang


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.